﻿namespace HostTracker.Azure.Management

open System
open System.ServiceModel
open System.ServiceModel.Web
open System.Runtime.Serialization
open FSharpExtensions
(*
<?xml version="1.0" encoding="utf-8"?>
<OperatingSystems xmlns="http://schemas.microsoft.com/windowsazure">
  <OperatingSystem>
    <Version>operating-system-version</Version>
    <Label>base64-encoded-label</Label>
    <IsDefault>true|false</IsDefault>
    <IsActive>true|false</IsActive>
    <Family>1|2</Family>
    <FamilyLabel>base64-encoded-label</FamilyLabel>
  </OperatingSystem>
</OperatingSystems>
*)
[<DataContract(Name="OperatingSystem", Namespace="http://schemas.microsoft.com/windowsazure")>]
type OperatingSystem() = 
    let mutable version = ""
    let mutable label = ""
    let mutable isDefault = false
    let mutable isActive = false
    let mutable family = 1
    let mutable familyLabel = ""
    [<DataMember(Name="Version", Order = 1)>]
    member x.Version with get () = version and set v = version <- v 
    [<DataMember(Name="Label", Order = 2)>]
    member private x.LabelEncoded with get () = label and set v = label <- v
    member x.Label with get () = label.FromBase64() and set (v: string) = label <- v.ToBase64()
    [<DataMember(Name="IsDefault", Order = 3)>]
    member x.IsDefault with get () = isDefault and set v = isDefault <- v
    [<DataMember(Name="IsActive", Order = 4)>]
    member x.IsActive with get () = isActive and set v = isActive <- v
    [<DataMember(Name="Family", Order = 5, IsRequired = false)>]
    member x.Family with get () = family and set v = family <- v
    [<DataMember(Name="FamilyLabel", Order = 6, IsRequired = false)>]
    member private x.FamilyLabelEncoded with get () = familyLabel and set v = familyLabel <- v
    member x.FamilyLabel with get () = familyLabel.FromBase64() and set (v: string) = familyLabel <- v.ToBase64()

[<CollectionDataContract(Name="OperatingSystems", Namespace="http://schemas.microsoft.com/windowsazure")>]
type OperatingSystems() = inherit System.Collections.Generic.List<OperatingSystem>()

(*
<?xml version="1.0" encoding="utf-8"?>
<OperatingSystemFamilies xmlns="http://schemas.microsoft.com/windowsazure">
  <OperatingSystemFamily>
    <Name>operating-system-family-name</Name>
    <Label>base64-encoded-label</Label>
    <OperatingSystems>
      <OperatingSystem>
        <Version>operating-system-version</Version>
        <Label>base64-encoded-label</Label> 
        <IsDefault>true|false</IsDefault>
        <IsActive>true|false</IsActive>
      </OperatingSystem>
    </OperatingSystems>
  </OperatingSystemFamily>
</OperatingSystemFamilies>
*)
[<DataContract(Name="OperatingSystemFamily", Namespace="http://schemas.microsoft.com/windowsazure")>]
type OperatingSystemFamily() = 
    let mutable name = ""
    let mutable label = ""    
    let mutable oss = OperatingSystems()
    [<DataMember(Name="Name", Order = 1)>]
    member x.Name with get() = name and set v = name <- v
    [<DataMember(Name="Label", Order = 2)>]
    member private x.LabelEncoded with get () = label and set v = label <- v
    member x.Label with get () = label.FromBase64() and set (v:string) = label <- v.ToBase64()
    [<DataMember(Name="OperatingSystems", Order = 3)>]
    member x.OSList with get () = oss and set v = oss <- v

[<CollectionDataContract(Name="OperatingSystemFamilies", Namespace="http://schemas.microsoft.com/windowsazure")>]
type OperatingSystemFamilies() = inherit System.Collections.Generic.List<OperatingSystemFamily>()

[<Interface>]
[<ServiceContract>]
type IOSManagement = 
    [<OperationContract>]
    [<WebInvoke(UriTemplate="/operatingsystems", Method = "GET")>]
    abstract ListOperatingSystems: unit -> OperatingSystems
    [<OperationContract(AsyncPattern = true)>]
    abstract BeginListOperatingSystems: callback:AsyncCallback*state:obj -> IAsyncResult
    abstract EndListOperatingSystems: result: IAsyncResult -> OperatingSystems
    [<OperationContract>]
    [<WebInvoke(UriTemplate="/operatingsystemfamilies", Method = "GET")>]
    abstract ListOperatingSystemFamilies: unit -> OperatingSystemFamilies
    [<OperationContract(AsyncPattern = true)>]
    abstract BeginListOperatingSystemFamilies: callback:AsyncCallback*state:obj -> IAsyncResult
    abstract EndListOperatingSystemFamilies: result: IAsyncResult -> OperatingSystemFamilies